package com.demo.bigdata

import org.apache.spark.{SparkConf, SparkContext}

object OptionDemo {
  def main(args: Array[String]): Unit = {
    val conf = (new SparkConf).setMaster("local").setAppName("Demo");
    val sc = new SparkContext(conf)
    val lines = sc.parallelize(List(("Hadoop",null),("Spark",1),("Hive",5),("Hbase",1)))
    lines.map(x=>nvl(x._2)).foreach(println)
  }
  def nvl(value: Any):Any={
    if(value==null) 0 else value
  }
}
